import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/page/repair_factory/accessories_query/VIN_Query.dart';
import 'package:ytbusiness/page/repair_factory/accessories_query/car_license.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

//配件查询
class AccessoriesQuery extends StatefulWidget {
  @override
  _AccessoriesQueryState createState() => _AccessoriesQueryState();
}

class _AccessoriesQueryState extends State<AccessoriesQuery>
    with TickerProviderStateMixin {
  TabController _tabController; //tab控制器
  List<String> titleList = ["VIN查询", "行驶证识别"];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = new TabController(length: titleList.length, vsync: this);

    _tabController.addListener(() {
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: customAppBar(context, title: "配件查询"),
        body:  Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              margin: EdgeInsets.only(left: setWidth(20), top: setWidth(36)),
              child: TabBar(
                controller: _tabController,
                isScrollable: true,
                labelColor: YTTheme.theme,
                labelStyle: TextStyle(
                    fontSize: setSp(18), fontWeight: FontWeight.w600),
                unselectedLabelColor: Color(0xff323232),
                unselectedLabelStyle:
                TextStyle(color: Colors.white, fontSize: setSp(15)),
                indicator: const BoxDecoration(),
                tabs: titleList
                    .asMap()
                    .map((key, value) {
                  return MapEntry(key, _tabItem(titleList[key]));
                })
                    .values
                    .toList(),
              ),
            ),
            Expanded(
              child: TabBarView(
                  controller: _tabController,
                  children: [
                    //VIN查询
                    VINQuery(),
                    //车牌号识别
                    CarLicense(),
                  ]),
            )

          ],
        ),
      ),
    );
  }

  Widget _tabItem(String title) {
    return Tab(text: title);
  }




}
